package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzEquipmentCapacity;
import com.ruoyi.business.service.ICzEquipmentCapacityService;
import com.ruoyi.common.utils.poi.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备能力Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "设备能力")
@RestController
@RequestMapping("/business/equipment_capacity")
public class CzEquipmentCapacityController extends BaseController
{
    @Autowired
    private ICzEquipmentCapacityService czEquipmentCapacityService;

    /**
     * 查询设备能力列表
     */
    @ApiOperation(value = "查询设备能力列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzEquipmentCapacity czEquipmentCapacity)
    {
        startPage();
        List<CzEquipmentCapacity> list = czEquipmentCapacityService.selectCzEquipmentCapacityList(czEquipmentCapacity);
        return getDataTable(list);
    }

    /**
     * 导出设备能力列表
     */
    @ApiOperation(value = "导出设备能力列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:export')")
    @Log(title = "设备能力", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzEquipmentCapacity czEquipmentCapacity)
    {
        List<CzEquipmentCapacity> list = czEquipmentCapacityService.selectCzEquipmentCapacityList(czEquipmentCapacity);
        ExcelUtil<CzEquipmentCapacity> util = new ExcelUtil<CzEquipmentCapacity>(CzEquipmentCapacity.class);
        util.exportExcel(response, list, "设备能力数据");
    }

    /**
     * 获取设备能力详细信息
     */
    @ApiOperation(value = "获取设备能力详细信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:query')")
    @GetMapping(value = "/{equipmentCapacityId}")
    public AjaxResult getInfo(@PathVariable("equipmentCapacityId") String equipmentCapacityId)
    {
        return AjaxResult.success(czEquipmentCapacityService.selectCzEquipmentCapacityByEquipmentCapacityId(equipmentCapacityId));
    }

    /**
     * 新增设备能力
     */
    @ApiOperation(value = "新增设备能力")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:add')")
    @Log(title = "设备能力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzEquipmentCapacity czEquipmentCapacity)
    {
        return toAjax(czEquipmentCapacityService.insertCzEquipmentCapacity(czEquipmentCapacity));
    }

    /**
     * 修改设备能力
     */
    @ApiOperation(value = "修改设备能力")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:edit')")
    @Log(title = "设备能力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzEquipmentCapacity czEquipmentCapacity)
    {
        return toAjax(czEquipmentCapacityService.updateCzEquipmentCapacity(czEquipmentCapacity));
    }

    /**
     * 删除设备能力
     */
    @ApiOperation(value = "删除设备能力")
    @PreAuthorize("@ss.hasPermi('business:equipment_capacity:remove')")
    @Log(title = "设备能力", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentCapacityIds}")
    public AjaxResult remove(@PathVariable String[] equipmentCapacityIds)
    {
        return toAjax(czEquipmentCapacityService.deleteCzEquipmentCapacityByEquipmentCapacityIds(equipmentCapacityIds));
    }
}
